package com.example.wangkai.firstmap;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;

import java.util.List;

/**
 * Created by Administrator on 2016/11/3.
 */
public class LocNearAddressAdapter extends BaseAdapter {

    private Context context;
    private List<PoiInfo> nearList;
    private LayoutInflater inflater;

    public LocNearAddressAdapter(Context context, List<PoiInfo> nearList) {
        this.context = context;
        this.nearList = nearList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return nearList.size();
    }

    @Override
    public Object getItem(int position) {
        return nearList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_near, null);
            holder = new ViewHolder();
            holder.tvdata = (TextView) convertView.findViewById(R.id.textView);
            holder.ivicon = (ImageView) convertView.findViewById(R.id.imageView);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        Log.i("mybaidumap", "address地址是：" + nearList.get(position).address);
        holder.tvdata.setText(nearList.get(position).address);
        return convertView;
    }

    class ViewHolder {
        TextView tvdata;
        ImageView ivicon;
    }


}
